<?php

use think\migration\Migrator;
use think\migration\db\Column;

class SystemMenu extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('system_menu',array('engine'=>'InnoDB'));
        $table->addColumn('pid', 'integer',array('default'=>0,'comment'=>'父id'))
            ->addColumn('module', 'string',array('limit' => 20,'comment'=>'模块名'))
            ->addColumn('user_id', 'integer',array('limit' => 0,'comment'=>'创建者'))
            ->addColumn('title', 'string',array('limit' => 32,'comment'=>'菜单标题'))
            ->addColumn('href', 'string',array('limit' => 200,'comment'=>'地址'))
            ->addColumn('icon', 'string',array('limit' => 80,'comment'=>'图标'))
            ->addColumn('sort', 'boolean',array('limit' => 1,'default'=>0,'comment'=>'排序'))
            ->addColumn('status', 'boolean',array('limit' => 1,'default'=>0,'comment'=>'状态'))
            ->addColumn('is_sys', 'boolean',array('limit' => 1,'default'=>0,'comment'=>'是否系统菜单'))
            ->addColumn('type', 'boolean',array('limit' => 1,'default'=>0,'comment'=>'属性，能否被点击 0-不能，1-能'))
            ->addColumn('create_time', 'integer',array('default'=>'0','comment'=>'创建时间'))
            ->addColumn('update_time', 'integer',array('default'=>0,'comment'=>'更新时间'))
            ->addColumn('delete_time', 'integer',array('null'=>true,'comment'=>'删除时间'))
            ->create();
    }
}
